import scrapy


class ZongbangFollowallSpider(scrapy.Spider):
    name = "zongbang_followall"

    def start_requests(self):
        url = "https://fozhidaoxs.cc/paihang.html"
        yield scrapy.Request(url)

    def parse(self, response):
        tlis = response.xpath('//ul[@class="tli"]')
        if tlis:
            tli = tlis[0]
            books_urls = tli.xpath('./li/a/@href').extract()
            yield from response.follow_all(books_urls, callback=self.parse_chapter_list)

            # for req in response.follow_all(books_urls, callback=self.parse_chapter_list) :
            #     yield req

    def parse_chapter_list(self, response):
        capters = response.css('.listmain dd a::text').extract()[9:]
        print(capters)
